import 'package:demo/base/app_color.dart';
import 'package:demo/base/font_size.dart';
import 'package:flutter/material.dart';

class AppText extends StatelessWidget {
  final String title;
  final double fontSize;
  final Color color;
  final TextOverflow? overflow;
  final int? maxLines;
  final FontWeight fontWeight;
  final TextAlign textAlign;
  final TextDecoration? decoration;
  final bool? softWrap;

  const AppText(
    this.title,
    this.color,
    this.fontSize,
    this.fontWeight,
    this.textAlign, {
    this.decoration,
    this.maxLines,
    this.overflow,
    this.softWrap,
    Key? key,
  }) : super(key: key);

  factory AppText.h0(
    String title, {
    Color? color,
    TextOverflow? overflow,
    FontWeight weight = FontWeight.bold,
  }) =>
      AppText(
        title,
        color ?? AppColors.black(),
        AppFontSize.xxxxLarge,
        weight,
        TextAlign.start,
        overflow: overflow,
      );

  factory AppText.h1(
    String title, {
    Color? color,
    TextOverflow? overflow,
    textAlign = TextAlign.start,
    FontWeight weight = FontWeight.bold,
  }) =>
      AppText(
        title,
        color ?? AppColors.black(),
        AppFontSize.xxxLarge,
        weight,
        textAlign,
        overflow: overflow,
      );

  factory AppText.h2(
    String title, {
    Color? color,
    TextOverflow? overflow,
    textAlign = TextAlign.start,
    FontWeight weight = FontWeight.bold,
  }) =>
      AppText(
        title,
        color ?? AppColors.black(),
        AppFontSize.xxLarge,
        weight,
        textAlign,
        overflow: overflow,
      );

  factory AppText.h3(
    String title, {
    Color? color,
    TextOverflow? overflow,
    textAlign = TextAlign.start,
    FontWeight weight = FontWeight.bold,
  }) =>
      AppText(
        title,
        color ?? AppColors.black(),
        AppFontSize.xLarge,
        weight,
        textAlign,
        overflow: overflow,
      );

  factory AppText.h4(
    String title, {
    Color? color,
    TextOverflow? overflow,
    int? maxLines,
    textAlign = TextAlign.start,
    FontWeight weight = FontWeight.bold,
  }) =>
      AppText(
        title,
        color ?? AppColors.black(),
        AppFontSize.large,
        weight,
        textAlign,
        maxLines: maxLines,
        overflow: overflow,
      );

  factory AppText.label(
    String title, {
    Color? color,
    FontWeight? weight,
    int? maxLines,
    TextOverflow? overflow,
    TextDecoration? decoration,
    bool? softWrap,
    TextAlign? align,
  }) =>
      AppText(
        title,
        color ?? AppColors.black(),
        AppFontSize.normal,
        weight ?? FontWeight.normal,
        align ?? TextAlign.start,
        maxLines: maxLines,
        overflow: overflow,
        decoration: decoration,
        softWrap: softWrap,
      );

  factory AppText.largeLabel(
    String title, {
    Color? color,
    FontWeight? weight,
    int? maxLines,
    TextOverflow? overflow,
    TextDecoration? decoration,
    bool? softWrap,
    TextAlign? align,
  }) =>
      AppText(
        title,
        color ?? AppColors.black(),
        AppFontSize.xNormal,
        weight ?? FontWeight.normal,
        align ?? TextAlign.start,
        maxLines: maxLines,
        overflow: overflow,
        decoration: decoration,
        softWrap: softWrap,
      );

  @override
  Widget build(BuildContext context) {
    return Text(
      title,
      overflow: overflow ?? TextOverflow.ellipsis,
      textAlign: textAlign,
      maxLines: maxLines,
      softWrap: softWrap ?? false,
      style: TextStyle(
          fontFamily: 'Hans',
          fontSize: fontSize,
          fontWeight: fontWeight,
          height: 1.5,
          color: color,
          decoration: decoration ?? TextDecoration.none),
    );
  }
}
